package com.gjy.service;

import com.gjy.dao.ReportMapper;
import com.gjy.domain.Report;
import com.gjy.domain.ReportExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReportService {

    @Autowired
    ReportMapper reportMapper;

    public void updateReport(Report report){
        ReportExample example = new ReportExample();
        ReportExample.Criteria criteria = example.createCriteria();
        criteria.andCIdEqualTo(report.getcId());
        reportMapper.updateByExampleSelective(report,example);
    }

    public void add(Report report){
        reportMapper.insert(report);
    }

    public List<Report> findAll(){
        return reportMapper.selectByExample(null);
    }

    public void deleteReport(Report report) {
        ReportExample reportExample = new ReportExample();
        ReportExample.Criteria criteria = reportExample.createCriteria();
        criteria.andCIdEqualTo(report.getcId());
        reportMapper.deleteByExample(reportExample);
    }
}
